import { Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from 'midwayjs-cool-core';
import { Context } from 'vm';
import { teacherEntity } from '../../entity/teacher';
import { TeacherService } from '../../service/teacher';

/**
 * 描述
 */
@Provide()
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: teacherEntity,
  service:TeacherService,
  pageQueryOp:{
    // 让title字段支持模糊查询
    keyWordLikeFields: ['name'],
    // 让type字段支持筛选
    fieldEq: ['type','is_work'],
    where: async (ctx: Context) => {
      return [
        ['a.isDelete = :isDelete', { isDelete: false }]
      ]
    }
  },
  listQueryOp:{
    where: async (ctx: Context) => {
      return [
        ['a.isDelete = :isDelete', { isDelete: false }]
      ]
    },
  }
})
export class teacherAdminController extends BaseController {}
